<?php
require Yii::app()->basePath.'/modules/manage/util/MenuList.php';
?>
<div id="header-inner"  >
		<div id="home">
			<a href="../console/index" title="后台首页"></a>
		</div>
		<ul class="sf-menu" id="menubar" style="float: left;margin-left: 10px;" >
            <?php
            if($user['user']['loginname'] == 'administrator'){
                foreach($MenuList as $m){
                    ?>
                    <li class="top"><a><span class="normal"><?php echo $m['name'] ?></span></a>
                        <ul>
                            <?php
                            foreach($m['child'] as $c){
                                ?>
                                <li><a href="<?php echo $c['url']; ?>"><?php echo $c['name']; ?></a>
                                    <?
                                    if(isset($c['child'])){
                                        ?>
                                        <ul>
                                            <?php
                                            foreach($c['child'] as $l){
                                                ?>
                                                <li><a href="<?php echo $l['url']; ?>"><?php echo $l['name']; ?></a></li>
                                            <?php
                                            }
                                            ?>
                                        </ul>
                                    <?php
                                    }
                                    ?>
                                </li>
                            <?php
                            }
                            ?>
                        </ul>
                    </li>
                <?php
                }
            }else{
                //通过group权限进行过滤
                $admingrouppermission = $user['admingrouppermission'];
                $operpermissionarray = unserialize($user['admingrouppermission']['operpermissionarray']);
                if(sizeof($operpermissionarray)!=null){
                    foreach($MenuList as $m){
                        if(array_key_exists($m['enkey'],$operpermissionarray)){
                            ?>
                            <li class="top"><a><span class="normal"><?php echo $m['name'] ?></span></a>
                                <ul>
                                    <?php
                                    foreach($m['child'] as $c){
                                        if(array_key_exists($c['enkey'],$operpermissionarray) || $c['isopen']==true){
                                            ?>
                                            <li><a href="<?php echo $c['url']; ?>"><?php echo $c['name']; ?></a>
                                                <?
                                                if(isset($c['child'])){
                                                    ?>
                                                    <ul>
                                                        <?php
                                                        foreach($c['child'] as $l){
                                                            if(array_key_exists($l['enkey'],$operpermissionarray)){
                                                                ?>
                                                                <li><a href="<?php echo $l['url']; ?>"><?php echo $l['name']; ?></a></li>
                                                            <?php
                                                            }
                                                        }
                                                        ?>
                                                    </ul>
                                                <?php
                                                }
                                                ?>
                                            </li>
                                        <?php
                                        }
                                    }
                                    ?>
                                </ul>
                            </li>
                        <?php
                        }
                    }
                }

            }
            ?>

		</ul>
	</div>
<script type="text/javascript">
            $(document).ready(function() {
                $('#menubar').superfish({});
            });
</script>	